package com.kinptm.masterclock.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class ReleaseableAdapter<T> extends AbstractAdapter<T> {

    public ReleaseableAdapter(LayoutInflater inflater, ViewCreator<T> creator) {
        super(inflater, creator);
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup parent) {
        T data = mDataCache.get(pos);
        if (null == convertView) {
            convertView = mCreator.createView(mInflater, pos, data);
        } else {
            mCreator.releaseView(convertView, data);
            convertView = mCreator.createView(mInflater, pos, data);
        }
        return convertView;
    }
}
